<% include "/WEB-INF/includes/cabeceira.gtpl" %>

<div id="content" class="group">

<%
def sesion = request.getSession(true)
def usuario = sesion.usuario
def erro = request.getAttribute('erro') 
def mensaxeExito = request.getAttribute('mensaxe')
%>

<% if (erro) { %>
<div class="erro">
${erro?:''}
</div>
<% } %>

<% if (mensaxeExito) { %>
<div class="exito">
${mensaxeExito?:''}
</div>
<% } %>


<div id="container">
<div id="container-inner">

<h1>engade unha pregunta</h1>

<form id="formulario" method="POST" action="crea/pregunta">
       
       
<fieldset>
<p>aquí podes inserir unha pregunta sobre o teu concello ou calquera outro</p>


<div class="campo">
<label class="etiqueta" for="pregunta">Pregunta</label>
<textarea rows="120" cols="90" id="pregunta" name="pregunta"></textarea>
<span class="mensaje"></span>
</div>

<div class="campo">
<label class="etiqueta" for="concello">O concello</label>
<% include '/listaConcellos.groovy' %>
<span class="mensaje"></span>
</div>


  <div class="controls">
  
       
      <!--<a href="/" id="cancel" class="submit" name="cancel">Cancela</a>-->      
      <input id="submit" class="submit" name="submit" type="submit" 
          value="Garda pregunta"/>
      
          
    </div>
    

</fieldset>

</form>
</div>
</div>


</div> <!-- /content -->


<% include "/WEB-INF/includes/pe.gtpl" %>



<script src="js/jquery-1.4.1.js" type="text/javascript"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>


<script type="text/javascript">
jQuery(function() {
	var validator = jQuery("#formulario").validate({
		rules: {
			pregunta: {
		      required:true,
		      maxlength:250
		    },
			concello: "required"
		},
		messages: {
			pregunta: {
			 required: "Este campo é requirido",
			 maxlength:"Non podes exceder os 250 caracteres"
			},
			concello: "Tes que indicar o concello"
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				//error.appendTo( element.parent().next() );
				error.appendTo( element.next());
		},
		
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});
	
});	
	
	
</script>	


<% include "/WEB-INF/includes/fin.gtpl" %>


